//
//  MYGExpertTableViewCell.swift
//  MYDoctor
//
//  Created by chenjs on 2024/5/29.
//

import UIKit

class MYGExpertTableViewCell: UITableViewCell {

    var model:MYGAcademicExpertListModel?{
        didSet {
            guard let model = model else {return}
            nameLabel.text = model.expertCn
            hospitailLabel.text = model.hospital
            avar.sd_setImage(with: URL(string: model.photo),placeholderImage: UIImage(named: "head"))
        }
    }
    // MARK: - init
    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        selectionStyle = .none

        configUI()
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }

    // MARK: - UI
    private func configUI() {
        contentView.backgroundColor = .white
        contentView.addSubview(nameLabel)
        contentView.addSubview(hospitailLabel)
        contentView.addSubview(avar)
        contentView.addSubview(line)
        
        avar.snp.makeConstraints { make in
            make.centerY.equalToSuperview()
            make.left.equalTo(15)
            make.width.height.equalTo(50)
        }
        
        nameLabel.snp.makeConstraints { make in
            make.left.equalTo(avar.snp.right).offset(11)
            make.top.equalTo(avar.snp.top)
            make.right.equalToSuperview().inset(20)
        }
        
        hospitailLabel.snp.makeConstraints { make in
            make.left.equalTo(avar.snp.right).offset(11)
            make.bottom.equalTo(avar.snp.bottom)
            make.right.equalToSuperview().inset(27)
        }

        line.snp.makeConstraints { make in
            make.height.equalTo(0.5)
            make.left.bottom.right.equalToSuperview()
        }
        

       
    }
    private lazy var avar: UIImageView = {
        let imageV = UIImageView()
        imageV.image = UIImage(named: "head")
        imageV.layer.cornerRadius = 25
        imageV.layer.masksToBounds = true
        return imageV
    }()
    
    private lazy var nameLabel: UILabel = {
        let label = UILabel()
        label.font = .medium(16)
        label.textColor = .rgba(44, 44, 44, 1)
        return label
    }()
    
    private lazy var hospitailLabel: UILabel = {
        let label = UILabel()
        label.font = .regular(13)
        label.textColor = .rgba(128, 128, 128, 1)
        return label
    }()
    


    private lazy var line:UIView = {
        let line = UIView()
        line.backgroundColor = .rgba(238, 238, 238, 1)
        return line
    }()
}
